import Taro from "@tarojs/taro";
import { create } from "zustand";

type CommonStore = {
    selectedIndex: number;
    setSelectedIndex: (val: number) => void
}

export const useCommonStore = create<CommonStore>((set) => {
    const selectedIndex = Taro.getStorageSync("selectedIndex") || 0;
    return {
        selectedIndex,
        setSelectedIndex: (val) => {
            set({selectedIndex: val});
            Taro.setStorageSync("selectedIndex", val);
        }
    }
})